package cn.edu.jxust.core.domain.repository.impl;

import cn.edu.jxust.common.domain.entity.SiteAirType;
import cn.edu.jxust.core.infrastructure.mapper.SiteAirTypeMapper;
import cn.edu.jxust.core.domain.repository.SiteAirTypeService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;

/**
 * @author QiuKangming
 * @version 1.0
 * @description
 * @since 2020/07/23 09:42
 */
@Service
public class SiteAirTypeServiceImpl extends ServiceImpl<SiteAirTypeMapper, SiteAirType> implements SiteAirTypeService {

    @Resource
    private SiteAirTypeMapper siteAirTypeMapper;

    /**
     * 删除监测点监测的气体
     * @param siteId 监测点id
     * @return int
     */
    @Override
    public int delSiteAirBySiteId(Integer siteId) {

        QueryWrapper<SiteAirType> wrapper = new QueryWrapper<>();
        wrapper.eq("site_id", siteId);
        return siteAirTypeMapper.delete(wrapper);

    }

    /**
     * 根据监测点id查询该监测点是否有监测气体
     * @param siteId 监测点id
     * @return int
     */
    @Override
    public int getCountBySiteId(Integer siteId) {

        return siteAirTypeMapper.getCountBySiteId(siteId);

    }

}
